package com.sumer.psychology.space.application.command;

import com.mongodb.BasicDBObject;
import com.sumer.psychology.common.persistence.mongodb.AbstractMongoRepository;
import com.sumer.psychology.space.domain.MessageType;

/**
 * 空间服务
 * <p/>
 * Created by twer on 15/4/19.
 */
public class SpaceApplicationService extends AbstractMongoRepository {
    private static final String DB_NAME = "sumer_message";

    /**
     * 删除朋友消息
     *
     * @param messageId message id
     * @param ownerId   owner id
     */
    public void removeFriendMessage(String messageId, String ownerId) {
        db().getCollection(dbName()).remove(
                new BasicDBObject("_id", ownerId)
                        .append("messages.messageType", MessageType.FRIEND.toString())
                        .append("messageId", messageId));
    }

    @Override
    protected String dbName() {
        return DB_NAME;
    }
}
